<!DOCTYPE HTML>
<html>
<head>
<title><?php echo $subtask_details['desc']?></title>
<!-- css file -->
<link href="<?= $this->config->base_url(); ?>assets/css/bootstrap-responsive.css" rel="stylesheet">
<link rel="stylesheet" href="<?= $this->config->base_url(); ?>assets/css/bootstrap-red.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="<?= $this->config->base_url(); ?>assets/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="<?= $this->config->base_url(); ?>assets/js/bootstrap.min.js"></script>
<style>
	#comments_discussion{
		height: 350px;
		width: 100%;
		font-size: 11px;
		overflow-y: scroll;
	}
</style>
</head>
<body>
 <?php if(empty($special_notes)) {?>	
  	<?php }else{
		foreach($special_notes as $l){
		$last = $l->id;	
		}?>
		<div  id="comments_discussion">
		<table class="table table-condensed">
		<?php foreach($special_notes as $sn){?>
		<tr <?php if($last == $sn->id){ 
		echo 'id="last"';
		}?> >
		<td width="8%" valign="top" style="padding-left:5px" >
		<?php if(!$sn->profile_image) {?>
    <img class="img-polaroid" width="28" src="<?= $this->config->base_url(); ?>assets/images/users.png" />    
	<?php } else {?>
    <img class="img-polaroid" width="28" src="<?= $this->config->base_url(); ?>assets/uploads/<?= $sn->profile_image?>" />    
	<?php }?> 	
		</td>
		<td>
		<?php 
		if($this->ion_auth->is_client($this->session->userdata('user_id'))){
			echo ucfirst('Fedobe');
		}else {
		echo ucfirst($sn->username); 	
		}?> <span class="muted">on <?php echo $sn->timestamp; ?></span>
		<?php if(($sn->user_id == $this->session->userdata('user_id')) OR $this->ion_auth->is_admin( $this->session->userdata('user_id'))) {?>
		<span class="pull-right"> <a href="javascript:void(0)" onclick="delete_discussion(<?php echo $sn->id?>)"><i class="icon-trash"></i></a>  </span>
		<?php }?><br />
		<?php echo $sn->note; ?>			
		</td>		
		</tr>		
	<?php }?>
	</table>
	</div>
	<?php }?>
<div>
<small>Add Discussion To This Subtask</small>
<label>
<textarea rows="5" cols="5" class="span5" name="note" id="note"></textarea>
</label>
<input type="hidden" value="<?php echo $subtask_details['id'];?>" name="subtask_id" id="subtask_id" />
<input type="button" value="Add" class="btn btn-success pull-right" onclick="save_discuss()" id="submit_note"/>
<br/><br/>
</div>	
<script type="text/javascript">
$('#submit_note').click(function () {	
	if(!$('#note').val())
	{
	alert('Note Field is Required');	
	}
	else {	
	var notes = $('#note').val();
	var subtask_id = $('#subtask_id').val();
	$.post('<?= site_url('user/tasks/save_discussion');?>',{note : notes , subtaskid : subtask_id }, function(data) {
 	$('#note').val("");		
	  location.reload(); 
	 });
	}
})

function delete_discussion(Id){
	$.post('<?= site_url('user/tasks/delete_discussion');?>',{id : Id}, function(data) {		
	location.reload(); 
	});
}

</script>
</body>
</html>